<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .countdown {
      color: red;
      font-size: 20px;
    }

    .countdown .time {
      background-color: red;
      color: #fff;
      padding: 5px;
      border-radius: 3px;

    }
  </style>
</head>

<body>
  <div class="countdown">
    <span class="time hour">03</span>
    <span class="split">:</span>
    <span class="time minute">25</span>
    <span class="split">:</span>
    <span class="time second">43</span>
  </div>
  <script src="./js/format.js"></script>
  <script>

    var hourEl = document.querySelector('.hour')
    var minuteEl = document.querySelector('.minute')
    var secondEl = document.querySelector('.second')

    var endDate = new Date()
    endDate.setHours(24)
    endDate.setMinutes(0)
    endDate.setSeconds(0)
    endDate.setMilliseconds(0)

    setInterval(function () {
      var nowDate = new Date()

      var intervalTime = Math.floor((endDate.getTime() - nowDate.getTime()) / 1000)
      // console.log(
      //   intervalTime,
      //   Math.floor(intervalTime % 60),
      //   Math.floor(intervalTime / 60) % 60,
      //   Math.floor(intervalTime / 3600)
      // )
      hourEl.textContent = formatPadLeft(Math.floor(intervalTime / 3600))
      minuteEl.textContent = formatPadLeft(Math.floor(intervalTime / 60) % 60)
      secondEl.textContent = formatPadLeft(Math.floor(intervalTime % 60))
    }, 1000)



  </script>
</body>

</html>